{% block department_item %}
    <h3>{{ department_detail.name }}</h3>
 
    
    
{% block formcontent %}
{% if form.is_multipart %}
    <form enctype="multipart/form-data" method="post" id="dept_form" OnSubmit="return SubmitForm();">
{% else %}
    <form method="post" id="dept_form" onSubmit="return SubmitForm();">
{% endif %}
    <div>
        <fieldset class="aligned">
        {% for field in form %}
            <div class="form-row">
                {{ field.errors }}
                <div>
                    {{ field.label_tag }}
                    {{ field }}&nbsp;&nbsp;{% if field.field.required %}<font color="red">*</font>{% endif %}
                </div>
            </div>
        {% endfor %}
        {% if message_ok %}
          <div class="form-row message_ok" ><font color="green">{{ message_ok }}</font></div>
        {% endif %}
        </fieldset>
        <div class="submit-row">
            <input class="default" type="submit" name="_save" value="Сохранить"  />
        </div>
    </div>
</form>
{% endblock %}

{% comment %}
    {% for item in phone %}
        <p>{{ item.number }}</p>
    {% endfor %}
    <h6>Руководитель:</h6>
    <p>{{ boss.last_name }}</p>
    <h6>Сотрудники:</h6>
{% endcomment %}    
    
    <form method="post" id="employee_form" onSubmit="return Submit_Employee_Form();">
    
    <table width=100% border="1">
    <tr>
    <th width="50%">ФИО</th>
    <th>Шеф</th>
    <th>Мат. отв.</th>
    <th>IT</th>
    <th>Уволен</th>
    </tr>
    {% for item in employee %}
      <tr>
        <td>
          <p>{{ item.last_name }} {{ item.first_name }} {{ item.patronymic }}</p>
          <p>{{ item.post }}</p>
        </td>
        <td>
          <input type="hidden" name="empl_hid_{{item.id}}"/>
          <input type="checkbox" name="empl_id_boss_{{item.id}}" value="{{item.id}}" {% if item.boss %}checked="checked"{% endif %}  />
        </td>
        <td>
          <input type="checkbox" name="empl_id_responsible_{{item.id}}" value="{{item.id}}" {% if item.responsible %}checked="checked"{% endif %}/>
        </td>    
        <td>
          <input type="checkbox" name="empl_id_it_staff_{{item.id}}" value="{{item.id}}" {% if item.it_staff %}checked="checked"{% endif %}/>
        </td>
        <td>
          <input type="checkbox" name="empl_id_fired_{{item.id}}" value="{{item.id}}" {% if item.fired %}checked="checked"{% endif %}/>
        </td>  
      </tr>
    {% endfor %}   
    </table>
    <div class="submit-row">
      <input class="default" type="submit" name="_save" value="Сохранить"  />
    </div>
    
    </form>
<script type="text/javascript">initPhoneWidget(document.getElementById('id_phone'));</script>    

<script type="text/javascript">
function load_data(data, textStatus){
  $('#department_detail').html(data);
}


function SubmitForm(){
  var queryString = $('#dept_form').formSerialize(); 
  $.post('{% url department_detail department_detail.id %}', queryString, load_data, 'html'); 
  return false;
} 
 
function Submit_Employee_Form(){
  var queryString = $('#employee_form').formSerialize(); 
  $.post('{% url department_employee_update department_detail.id %}', queryString, load_data, 'html');
  return false;  
}
</script>

{% endblock %}
